package com.example.zhang;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;

import android.os.Bundle;

import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

public class Home_page extends AppCompatActivity {
    String title [] = {"在线翻译","六级单词本","我的收藏"};
    int pic [] = {R.drawable.pic2,R.drawable.pic3,R.drawable.pic1};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home_page);
        ViewPager2 viewPager = findViewById(R.id.viewpager2);
        Adaper_pager pageAdapter = new Adaper_pager(this);
        viewPager.setAdapter(pageAdapter);


        TabLayout tabLayout = findViewById(R.id.tab_layout);
        new TabLayoutMediator(tabLayout, viewPager,
                (tab, position) -> tab.setIcon(pic[position]).setText(title[position])
        ).attach();
    }
}